<template>
  <div class="dataAllContainer">
    <div class="mainContainer">
      <div class="title">
        模拟数据生成
      </div>
      <div class="main">
        <div id="main" style="width: 100%; height: 500px">
          <div style="margin-top: 20px; margin-left: 25%; margin-right: 25%">
            &nbsp;归属设备:&nbsp;
            <el-select
              v-model="deviceId"
              style="width: 200px"
              placeholder="请输入内容">
              <el-option v-for="item in deviceList" :key="item.id" :label="item.actionNo" :value="item.id"/>
            </el-select>
            &nbsp;数据类型:&nbsp;
            <el-select
              v-model="type"
              style="width: 200px"
              placeholder="请输入内容">
<!--              1温度2湿度3海拔4气压-->
              <el-option label="温度" value="1"></el-option>
              <el-option label="湿度" value="2"></el-option>
              <el-option label="海拔" value="3"></el-option>
              <el-option label="气压" value="4"></el-option>
            </el-select>
            &nbsp;&nbsp;
            <el-button type="primary" @click="generateData">刷新</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { deviceLists, generatorData } from "@/api";

export default {
  name: "GeneratorMonitor",
  data() {
    return {
      deviceId: "",
      deviceList: [],
      type: "",
    };
  },
  created() {
    this.getDevice();
  },
  methods: {
    getDevice() {
      deviceLists(0).then((res) => {
        this.deviceList = res;
      });
    },
    generateData(){
      generatorData(this.deviceId, this.type).then(() => {
        this.$message.success("生成成功");
      });
    },
  },
};
</script>

<style scoped lang="scss">
.dataAllContainer {
  display: flex;
  .title {
    color: #fff;
    text-align: center;
  }
  #main {
    border: 2px solid #003a78;
    border-radius: 5px;
    padding: 5px;
    background-color: #fff;
  }
  .mainContainer {
    width: 100%;
    margin-right: 10px;
    margin-left: 5px;
  }
}
</style>